#include "Unit.h"

#define  MILE_TO_YARD 1760
#define  YARD_TO_FEET 3
#define  FEET_TO_INCH 12

Unit::Unit(BritishUnit unitType, unsigned int unitValue)
{
  int times;
  switch(unitType)
  {
    case MILE:
      times = MILE_TO_YARD*YARD_TO_FEET*FEET_TO_INCH;
      break;
    case YARD:
      times = YARD_TO_FEET*FEET_TO_INCH;
      break;
    case FEET:
      times = FEET_TO_INCH;
      break; 
    default:
      times = 1; 
  }
  mUnitValue = (times * unitValue);
}

bool Unit::operator==(const Unit& unit) const
{
  return (this->mUnitValue == unit.mUnitValue);
}

Unit Unit::operator+(const Unit& unit) const
{
   return Unit(INCH,this->mUnitValue + unit.mUnitValue); 
}
